window.addEventListener('pageshow', function() {
    var share = this.document.querySelector('.share'); //分享按钮
    var share_to = this.document.querySelector('.share_to'); //分享栏
    var article = document.querySelector('.article_page'); //文章
    share.addEventListener('click', function() {
        var startY = 0;
        var moveY = 0;
        var flag = false;
        clearTimeout(timer);
        share_to.style.display = 'block';
        var timer = setTimeout(() => {
            share_to.style.transition = 'all 0.3s ease-out';
            share_to.style.transform = 'translateY(0)';
        }, 200);
        //点击其他地方 关闭分享栏
        article.addEventListener('click', function(e) {
            if (e.pageY > share_to.offsetHeight) {
                close_share();
            }
        })

    })

    //关掉分享栏
    function close_share() {
        share_to.style.transition = 'all 0.s ease-out';
        share_to.style.transform = 'translateY(100%)';
        clearTimeout(timer);
        var timer = setTimeout(() => {
            share_to.style.display = 'none';
        }, 500);
        console.log(1);

    }

    /*     // 屏幕向下滑动 关闭分享栏
        function close_share_animate() {
            //var startY = 0;
            //var moveY = 0;
            //var flag = false;
            document.addEventListener('touchstart', function(e) {
                startY = e.targetTouches[0].pageY;
            });
            document.addEventListener('touchmove', function(e) {
                // 移动距离
                moveY = e.targetTouches[0].pageY - startY;
                flag = true; // 如果用户手指移动过我们再去判断否则不做判断效果
                e.preventDefault(); // 阻止滚动屏幕的行为
            })
            document.addEventListener('touchend', function(e) {
                if (flag) {
                    // (1) 如果移动距离大于50像素，收回transform: translateY(100%);
                    if (Math.abs(moveY) > 20) {
                        // 如果向下划 收回
                        close_share();
                    }
                }
            })
        }
     */
})